1. Field of the Invention
The present invention relates generally to, and more particularly to object-oriented computing environments, and in particular to assessing a protected resource of an object of a first class by an object of a second class in an object-oriented computing environment.
2. Description of Related Art
In an object-oriented computing environment in a computer system, the resources provided by instances of classes can be defined as pubic, or as private. Instances of other classes can access instances of classes defined as public. However, instances of other classes normally cannot access instances of classes defined as private.
Some computer programming languages do provide a way of allowing an instance of one class to access protected resources of the instance of another class. For example, the C++ computer programming language provides a keyword friend that lets a first class specify a set of classes as friend classes. Instances of the friend classes can access the resources of instances of the first class. Keyword friend effectively opens up all of the resources of instances the first class, as the implementation of keyword friend does not allow an explicit set of resources to be specified that can be accessed by a friend class instance.
Thus, the known keyword friend approach in the C++ computer programming language can be used to allow access by a client to the resources of a supplier. However, this is only possible if the client had been specifically identified as a friend in the supplier. Moreover, each time the list of clients to be classed as friends of the supplier changes, the supplier has to be re-written to accommodate the change.
Each time the supplier is re-written to accommodate a change, this is a potential source of error, particularly if it is expected that a list of clients with access to the supplier is frequently changing. Moreover, once a client has been identified as a friend of the supplier, the client then has access to all of the resources of the supplier. This mechanism does not allow for access to only selected resources of the supplier.
Further information on the C++ computer programming language, including the use of “friends”, can be found in “The C++ Programming language, Special Edition” by Bjarne Stroustrup, published by Addison Wesley, Reading Mass. (ISBN 0-201-70073-5). Also, various object-oriented computer programming techniques are described in “Design Patterns—Elements of Reusable Object-Oriented Software” by E Gamma et al, published by Addison Wesley, Reading Mass. (ISBN 0-201-63361-2).
One technique, called a bridge pattern, and also known as a handle-body, enables an abstraction to be decoupled from its implementation so that the two can vary independently. When an abstraction can have several possible implementations, the usual way to address this is to use inheritance. However, inheritance binds an implementation to the abstraction permanently. The bridge pattern avoids problems caused by this binding by putting the abstraction and its implementation into different class hierarchies.
Another technique is called a proxy, or surrogate, which provides a surrogate or placeholder for another object to control access to that object. One potential use for a proxy is where the creation of a real object, e.g. an image, can be expensive in processing terms. Ideally therefore, such a real object should only be created on demand. To hide that the real object is only created on command, the proxy approach provides that another object, a proxy, acts as a stand-in for the real object until the real object is to be created.